#ifndef QMLCPPINTERFACE_H
#define QMLCPPINTERFACE_H

#include <QObject>
#include <QDebug>
#include <QString>
#include <QTcpSocket>
#include <QTcpServer>

class QmlCppInterface : public QObject
{
    Q_OBJECT
public:
    explicit QmlCppInterface(QObject *parent = 0);

signals:
    void connected();
    void waitingForConnection();
    void msgReceived(QVariant msg);
    void disconnected();

public slots:
    void connect(const QString& addr);
    void sendMsg(const QString& msg);
    void disconnect();

private slots:
    void connError(QAbstractSocket::SocketError);
    void connEstabilished();
    void newConnectionSlot();
    void blockReceived();
    void disconnectedSlot();

private: //functions
    QString changeText();
    void startServer();

private:
    QTcpSocket* m_socket;
    QTcpServer* m_server;
    QString m_newText;
    quint16 m_msgSize;
};

#endif // QMLCPPINTERFACE_H
